import request from '@/utils/request'

export function fetchList(params) {
  return request({
    url: '/back/ums/role/page',
    method: 'get',
    params: params
  })
}

export function createRole(data) {
  return request({
    url: '/back/ums/role/insert',
    method: 'post',
    data: data
  })
}

export function updateRole(id, data) {
  data.id = id
  return request({
    url: '/back/ums/role/update',
    method: 'put',
    data: data
  })
}

export function updateStatus(id, params) {
  params.id = id
  return request({
    url: '/back/ums/role/updateStatus',
    method: 'put',
    data: params
  })
}

export function deleteRole(id) {
  return request({
    url:'/back/ums/role/delete/' + id,
    method:'delete'
  })
}

export function fetchAllRoleList() {
  return request({
    url: '/back/ums/role/list',
    method: 'get'
  })
}

export function listMenuByRole(roleId) {
  return request({
    url: '/back/ums/role/hasMenuPermission/'+roleId,
    method: 'get'
  })
}

export function listResourceByRole(roleId) {
  return request({
    url: '/back/ums/role/hasResourcePermission/'+roleId,
    method: 'get'
  })
}

export function allocMenu(data) {
  return request({
    url: '/back/ums/role/allotMenu',
    method: 'post',
    data: data
  })
}

export function allocResource(data) {
  return request({
    url: '/back/ums/role/allotResource',
    method: 'post',
    data:data
  })
}
